{include file="public/header" /}
{load href="__PLUGINS__bootstrap/bootstrap-table.min.css"}
{load href="__PLUGINS__bootstrap/bootstrap-table.min.js"}
<style>
    #des, #des input {
        width: 40px;
        text-align: center;
    }

    #id {
        width: 78px;
    }

    .bs-checkbox {
        width: 36px;
        height: 40px
    }

    .fixed-table-toolbar .columns, .fixed-table-toolbar .search {
        margin-left: 0;
        margin-top: 0
    }

    #title span {
        float: right;
    }

    .asdlkjasd {
        background: #1ab394;
        color: #fff
    }
</style>
<body class="gray-bg">
<div class="wrapper wrapper-content {:config('adminClass.main')}">
    <div class="ibox float-e-margins">
        {include file="public/tophead"}
        {include file="public/top" /}
        <div class="ibox-content">
            {include file="public/topsection"}
            <div class="row row-lg">
                <div class="col-sm-12">
                    <div class="fixed-table-toolbar">
                        <a class="btn btn-default btn-outline {present name='status'}{else /}asdlkjasd{/present}" href="{:url('topupPrevRecords')}">全部</a>
                        <a class="btn btn-default btn-outline {eq name='status' value='0'}asdlkjasd{/eq}" href="{:url('topupPrevRecords',['status'=>0])}">审核</a>
                        <a class="btn btn-default btn-outline {eq name='status' value='1'}asdlkjasd{/eq}" href="{:url('topupPrevRecords',['status'=>1])}">完成</a>
                        <a class="btn btn-default btn-outline {eq name='status' value='-1'}asdlkjasd{/eq}" href="{:url('topupPrevRecords',['status'=>-1])}">拒绝</a>
                    </div>
                    <div style="display:block;clear: both;"></div>
                    <div class="fixed-table-toolbar">
                        <form  method="get" action="" style="display: flex;">
                            <div class="pull-left search" style="display: flex;">
                                <div class="columns columns-right btn-group pull-left">
                                    <select class="form-control" name="search">
                                        <option value="user_id" {php}if(input('?param.search')){if(input('param.search')=='user_id'){echo "selected";} }{/php}>用户ID</option>
                                        <option value="parent_id" {php}if(input('?param.search')){if(input('param.search')=='parent_id'){echo "selected";} }{/php}>上级ID</option>
                                    </select>
                                </div>
                                <div class="pull-right search">
                                    <input class="form-control input-outline" type="text"
                                           {php}
                                           if(input('?param.name')){
                                    if(input('param.name')){
                                    echo "value='".input('name')."'";
                                    }

                                    }
                                    {/php}
                                    name="name" placeholder="搜索">
                                </div>

                                <div class="pull-right search">
                                    <button style="border-radius:0px; border:1px solid #e5e6e7; border-left:0px" class="btn btn-default btn-outline" type="submit">搜索</button>
                                </div>

                                {php}
                                if(input('?param.name')){
                                {/php}
                                <div class="pull-right search">
                                    <a class="btn btn-w-m btn-link" href="{:url('topupPrevRecords')}">返回管理</a>
                                </div>{php}
                                }
                                {/php}


                            </div>
                        </form>
                    </div>
                    <div class="example">
                        <form class="form-horizontal" method="post">
                            <table data-toggle="table">
                                <thead>
                                <tr>
                                    <th data-align="center">ID</th>
                                    <th data-align="center">用户</th>
                                    <th data-align="center">上级</th>
                                    <th data-align="center">充值积分</th>
                                    <th data-align="center">邀请时间</th>
                                    <th data-align="center">邀请前充值金额(元)</th>
                                    <th data-align="center">状态</th>
                                    <th data-align="center">创建时间</th>
                                    <th data-align="center">更新时间</th>
                                    <th data-align="center">管理</th>
                                </tr>
                                </thead>
                                <tbody id="form">
                                {volist name="data" id="v"}
                                <tr id="id{$v.id}" class="class">
                                    <td>{$v.id}</td>
                                    <td><a onclick="member('{$v.user_id}')" style="color:#40BCF7">{if condition='isset($users[$v.user_id])'}{$users[$v.user_id]['name']}({$v.count}次){/if}</a><br/>(ID：{$v.user_id})</td>
                                    <td><a onclick="member('{$v.parent_id}')" style="color:#40BCF7">{if condition='isset($users[$v.parent_id])'}{$users[$v.parent_id]['name']}{/if}</a><br/>(ID：{$v.parent_id})</td>
                                    <td>{$v.money}</td>
                                    <!-- <td>{:date('Y-m-d H:i:s', $v.data['invite_time'])}</td> -->
                                    <td>{if condition='isset($users[$v.user_id])'}{$users[$v.user_id]['register_datetime']}{/if}</td>
                                    <td>{$v.data['topup_total']}</td>
                                    <td>
                                        {switch name="v.status"}
                                            {case value="0"}审核{/case}
                                            {case value="1"}<font color="#1ab394">通过</font>{/case}
                                            {case value="-1"}<font color="#f00">拒绝</font>{/case}
                                        {/switch}
                                    </td>
                                    <td><span {if condition="date('Ymd')==date('Ymd',$v.create_time)"}style="color: #ed5565"{/if}>{:date('Y-m-d H:i', $v.create_time)}</span></td>
                                    <td><span {if condition="date('Ymd')==date('Ymd',$v.update_time)"}style="color: #ed5565"{/if}>{:date('Y-m-d H:i', $v.update_time)}</span></td>
                                    <td>
                                        <div class="btn-group">
                                            <div data-toggle="dropdown" class="btn btn-primary btn-xs dropdown-toggle">操作 <span class="caret"></span>
                                            </div>
                                            <ul class="dropdown-menu">
                                                {eq name='admin.type' value='1'}
                                                    {switch name="v.status"}
                                                        {case value="0"}
                                                            <li><a onClick="shenhe({$v.id},'1')"><span style="color: #1ab394; ">通过</span></a></li>
                                                            <li class="divider"></li>
                                                            <li><a onClick="shenhe({$v.id},'-1')"><span style="color: #ed5565; ">拒绝</span></a></li>
                                                            <li class="divider"></li>
                                                        {/case}
                                                    {/switch}
                                                    <li><a onclick="del('{$v.id}')">删除</a></li>
                                                {/eq}
                                            </ul>
                                        </div>
                                    </td>
                                </tr>
                                {/volist}
                                </tbody>
                            </table>
                        </form>
                    </div>
                </div>
            </div>
            <hr>
            <div class="row row-lg">
                <div class="col-sm-12 pages">{$page}</div>
            </div>
        </div>
    </div>
</div>
{include file="public/footer" /}

<script type="text/javascript">
    function del(id){
        swal_del(id,"{:url('topupPrevDel')}")
    }

    function member(id)
    {
        layui.use('layer', function(){
            var layer = layui.layer;
            layer.open({
                title :'预览',
                area: ['100%', '100%'],
                type: 2,
                content: '{:url("member/index")}?search=id&name='+id
            });
        });
    }

    function shenhe(id,value){
        ajaxFun("post","{:url('topupPrevAdd')}",{id:id,status:value},'json',function(ret){
            if(ret){
                if(ret.ret){
                    layer.msg(ret.ret)
                    /*$("#id"+id).hide('fast',function(){
                         $("#id"+id).remove();
                    })*/
                    window.location.reload()
                }else{
                    layer.msg(ret.err)
                }
            }else{
                swal_msg("错误",ret,"error");
            }
        })
    }

</script>
 